package ru.stork.vasilisa.model

import com.yelbota.util.Lazy
import ru.stork.vasilisa.lang

trait Namespace extends NotNull with Immutable {

  type NsDef = List[String]

  val imports:List[ImportDef];
  val local:NsDef;

  def configure(imports: List[ImportDef], local:NsDef): Namespace
  def addPrivateDeclarations(value: Map[String, Lazy[VasilisaType]]): Namespace
  def findTrait(name: String): Option[Lazy[VasilisaType]]
}

object ImportDef {

  import com.wordpress.michid.Memoize._

  private def _fromNode(node: lang.Import) =
    new ImportDef(node.pkg, node.name)

  val fromNode = memoize(_fromNode _)
}

final class ImportDef(val pkg:List[String], val name: String)